﻿using System;
using EasyStep.Attributes;
using EasyStep.TestExecution.Data;
using EasyStep.TestExecution.Interfaces;
using OpenQA.Selenium;
using EasyStep.TestActions.Utils;
using OpenQA.Selenium.Support.UI;

namespace EasyStep.TestActions.Actions.Wait
{
    [TestAction(typeof(Wait), Name = "ExplicitlyById")]
    class ExplicitWaitById : ITestAction<IWebDriver>
    {

        public void Execute(IWebDriver browser, TestStepResult data, IExecuteDataContext context)
        {
            WebDriverWait Wait = new WebDriverWait(browser, TimeSpan.FromMilliseconds(Convert.ToDouble(data.Data)));
            Wait.Until<IWebElement>(el => el.FindElement(By.Id(data.Locator)));
        }
    }
}